﻿<%@ WebHandler Language="C#" Class="viewWinning" %>

using System;
using System.Web;
using System.Collections.Generic;
using OneshoppingWeb;
using OneShoppingModel;
using OneShoppingBLL;
using OneShoppingUtility;
using System.Web.SessionState;

public class viewWinning : IHttpHandler, IRequiresSessionState
{
    
    public void ProcessRequest (HttpContext context) {
        try
        {
            int listId = Convert.ToInt32(context.Request["listId"]);
            SystemUser user = (SystemUser)context.Session["user"];
            List<viewHistory> list = viewHistoryBLL.GetInstance().GetList(r=>r.ListId==listId && r.UserId==user.UserId);
            List<activityH> lh = new List<activityH>();
            foreach (var item in list) {
                activityH ah = new activityH();
                ah.buyTime = item.BuyTime.ToString();
                ah.code = item.TradeCode.ToString();
                switch (item.BuyStatus) {
                    case 0: ah.status = "未开奖"; break;
                    case 1: ah.status = "中奖"; break;
                    case 2: ah.status = "未中奖"; break;
                    case 3: ah.status = "活动失败"; break;
                }
                lh.Add(ah); 
            }
         
            context.Response.Write(JsonHelper.SerializeObject(lh));
        }
        catch
        {
            context.Response.Write((int)Protocol_activity.GET_EXCEPTION);//获取异常
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
    private class activityH {
        public String buyTime { set; get; }
        public String code { set; get; }
        public String status { set; get; }
    }
    
}